package com.example.mobile2021606144ywr0407homework;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity5 extends AppCompatActivity {

    private TextView tvMainTitle4;
    private TextView tvMain41;
    private TextView tvMain42;
    private TextView tvMain43;
    private EditText editMain41;
    private Button btnMain4End;
    private TextView txt3;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main5);
        initView();
        btnMain4End.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String string = editMain41.getText().toString();
                int num=Integer.valueOf(string).intValue();
                double a = 5*(num - 39)/9;
                String b = String.format("%.3f", a);
               txt3.setText("摄氏度为"+b);
            }
        });
    }

    private void initView() {
        tvMainTitle4 = (TextView) findViewById(R.id.tv_main_title4);
        tvMain41 = (TextView) findViewById(R.id.tv_main4_1);
        tvMain42 = (TextView) findViewById(R.id.tv_main4_2);
        tvMain43 = (TextView) findViewById(R.id.tv_main4_3);
        editMain41 = (EditText) findViewById(R.id.edit_main4_1);
        btnMain4End = (Button) findViewById(R.id.btn_main4_end);
        txt3 = (TextView) findViewById(R.id.txt3);
    }
}